;(function() {
		'use strict';
		angular.module('services.resourcesWatchData.detInfoDisplay')
			.factory('detInfoDisplayService', detInfoDisplayService);

		function detInfoDisplayService(Restangular) {
			return {
				//查询主机详细信息
				queryInfo: function(params, callback) {
					Restangular.all('sas/resourceMonitoring/hostdetMessage/hostInfo').post(params).then(callback);
				},
				//状态
				queryState: function(params, callback) {
					Restangular.all('sas/resourceMonitoring/hostdetMessage/hostState').post(params).then(callback);
				},
				//状态cpu下钻
				queryCpuNat: function(params, callback) {
					Restangular.all('sas/resourceMonitoring/hostdetMessage/cpuNat').post(params).then(callback);
				},
				//状态硬盘下钻
				queryDiskNat: function(params, callback) {
					Restangular.all('sas/resourceMonitoring/hostdetMessage/diskNat').post(params).then(callback);
				},
				//状态内存下钻
				queryRamNat: function(params, callback) {
					Restangular.all('sas/resourceMonitoring/hostdetMessage/ramNat').post(params).then(callback);
				},
				//状态网络下钻
				queryInterNat: function(params, callback) {
					Restangular.all('sas/resourceMonitoring/hostdetMessage/interNat').post(params).then(callback);
				},
				//进程
				queryProcess: function(params, callback) {
					Restangular.all('sas/resourceMonitoring/hostdetMessage/hostProcess').post(params).then(callback);
				},
				//资源
				queryResources: function(params, callback) {
					Restangular.all('sas/resourceMonitoring/hostdetMessage/hostResource').post(params).then(callback);
				},
				//组件
				queryComponent: function(params, callback) {
					Restangular.all('sas/resourceMonitoring/hostdetMessage/hostComponent').post(params).then(callback);
				},
				getEchartsPieData: function(res, temp) {
					var option = {
						title: {
							text: temp.echartsPieTitle,
							x: 'center'
						},
						animation: false,
						legend: {
							show: true,
							orient: 'vertical',
							x: 'right',
							y: 'center',
							data: temp.echartsPieLegend
						},
						series: [{
							type: 'pie',
							radius: '55%',
							center: ['50%', '60%'],
							itemStyle: {
								normal: {
									label: {
										formatter: function(params) {
											return params.name + '\n' + (params.percent - 0).toFixed(0) + '%';
										}
									},
									labelLine: {
										show: true
									}
								}
							},
							data: temp.echartsPieSeriesData
						}]
					};
					return option;
				},
				getEchartsData: function(res) {
					var temp = {
						echartsX: [],
						rate: []
					};
					angular.forEach(res.data, function(rd){
						temp.echartsX.push(rd.time);
						temp.rate.push(rd.rate);
					});
					var option = {
						title: {
							text: 'CPU',
							x: 'center'
						},
						animation: false,
						grid: {
							x2: 100
						},
						tooltip: {
							show: true
						},
						xAxis: [{
							type: 'category',
							axisLabel: {
								show: false
							},
							data: temp.echartsX
						}],
						yAxis: [{
							type: 'value',
							name: '使用比率'
						}],
						series: [{
							type: 'line',
							data: temp.rate
						}]
					};
					return option;
				},
				getState : function(){
					return [{
						stateCode:'1',stateName:'良好'
					},{
						stateCode:'2',stateName:'隐患'
					},{
						stateCode:'3',stateName:'不良'
					}];
				},
				getMaintainMode:function(){
					return [{
						modeCode:'1',modeName:'是'
					},{
						modeCode:'2',modeName:'否'
					}];
				}
			};
		}
})();